/**
 * 绑定home页面的点击事件
 * @param {type} lng
 * @param {type} App
 * @returns {undefined}
 */
(function (lng, App) {

    var _router = App.Router;
    var _view = App.View;
    var _presenter = App.Presenter;
    var _element = App.Data.Element;
    var _binder = App.Binder;
    var _Custom = App.Model.Custom;
    var $ = lng.dom;

    _binder.section_binder[_element.SECTIONS.HOME] = {
        // the header nav
        'a#home-hnav-yelpages':function () {
            _router.gotoArticle(_element.SECTIONS.YELPAGES, PAGE_YELPAGES);
        },
        // the footer nav
        'a#home-fnav-info':function () {
            _router.gotoArticle('home', PAGE_HOME_INFO, 'home-fnav-info');
        },
        'a#home-fnav-custom':function () {
            _router.gotoArticle('home', PAGE_HOME_CUSTOM, ['home-fnav-custom', 'home-hnav-mycustom']);
        },
        'a#home-fnav-raid':function () {
            _router.gotoArticle('home', PAGE_HOME_RAID, 'home-fnav-raid');
        },
        'a#home-fnav-more':function () {
            _router.gotoArticle('home', PAGE_HOME_MORE, 'home-fnav-more');
        },
        'a#home-fnav-add':function () {
            _view.HomeInfoPage.toggleFloatShortbar();
        },
        // the shortbar
        'a#home-shortbar-intention':function () {
            _router.gotoArticle(_element.SECTIONS.GROUPING, PAGE_GROUPING);
            _presenter.GroupingPagePresenter.setData({
                type:_Custom.TYPE_INTENTION
            });
        },
        'a#home-shortbar-addcustom':function () {
            _router.gotoArticle(_element.SECTIONS.CUSTOM, PAGE_CUSTOM);
            _presenter.CustomPagePresenter.setData({
                action:_presenter.CustomPagePresenter.ACTION_TYPE.ADD
            });
        },
        'a#home-shortbar-addvisit':function () {
            _router.gotoArticle(_element.SECTIONS.VISIT, PAGE_VISIT);
        },
        // the info page
        'a#home-info-intention':function () {
            // 马上成交
            _router.gotoArticle(_element.SECTIONS.GROUPING, PAGE_GROUPING);
            _presenter.GroupingPagePresenter.setData({
                type:_Custom.TYPE_INTENTION
            });
        },
        'a#home-info-edit':function () {
            // 编辑月度目标
            // 隐藏编辑
            var $_mouth_target = $('label#home-month-target-label');
            var mouth_target = $_mouth_target.html();
            $_mouth_target.hide();
            $('a#home-info-edit').hide();

            // 显示输入框
            var $_mouth_target_input = $('input#home-month-target-input');
            $_mouth_target_input.val(mouth_target);
            $_mouth_target_input.show();
            $('a#home-info-save').show();
        },
        'a#home-info-save':function () {
            // 编辑月度目标

            var $_mouth_target_input = $('input#home-month-target-input');
            var mouth_target = $_mouth_target_input.val();
            //$_mouth_target_input.val(mouth_target);
            $_mouth_target_input.hide();
            $('a#home-info-save').hide();

            var $_mouth_target = $('label#home-month-target-label');
            $_mouth_target.html(mouth_target);
            $_mouth_target.show();
            $('a#home-info-edit').show();
        },
        // the custom page
        // 添加客户按钮
        'a#home-custom-add':function () {
            _router.gotoArticle(_element.SECTIONS.CUSTOM, PAGE_CUSTOM);
            _presenter.CustomPagePresenter.setData({
                action:_presenter.CustomPagePresenter.ACTION_TYPE.ADD
            });
        },
        'a#home-search-custom':function () {
            // 搜索客户
            var keyword = $('input#home-input-search').val();
            _router.gotoArticle(_element.SECTIONS.GROUPING, PAGE_GROUPING);
            _presenter.GroupingPagePresenter.setData({
                type:_Custom.TYPE_NONE,
                keyword:keyword
            });
        },
        'a#home-custom-intention-btn':function () {
            // 意向客户
            _router.gotoArticle(_element.SECTIONS.GROUPING, PAGE_GROUPING);
            _presenter.GroupingPagePresenter.setData({
                type:_Custom.TYPE_INTENTION
            });
        },
        'a#home-custom-deal-btn':function () {
            // 成交客户
            _router.gotoArticle(_element.SECTIONS.GROUPING, PAGE_GROUPING);
            _presenter.GroupingPagePresenter.setData({
                type:_Custom.TYPE_DEAL
            });
        },
        'a#home-custom-month-btn':function () {
            // 本月客户
            _router.gotoArticle(_element.SECTIONS.GROUPING, PAGE_GROUPING);
            _presenter.GroupingPagePresenter.setData({
                type:_Custom.TYPE_THISMONTH
            });
        },
        'a#home-custom-all-btn':function () {
            // 全部客户
            _router.gotoArticle(_element.SECTIONS.GROUPING, PAGE_GROUPING);
            _presenter.GroupingPagePresenter.setData({
                type:_Custom.TYPE_NONE
            });
        }
    };
})(Lungo, App);